package com.zhuozhou.jdyc.main.meinfo.adapter;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.base.BaseRecyclerViewAdapter;
import com.zhuozhou.jdyc.base.BaseViewHolder;
import com.zhuozhou.jdyc.databinding.AdapterScShopBinding;
import com.zhuozhou.jdyc.main.meinfo.bean.CollectBean;

/**
 * Create by Once_ChuXy on 2021/10/5
 * Describe:
 */
public class SCShopAdapter extends BaseRecyclerViewAdapter<CollectBean, AdapterScShopBinding> {
    private int type = 0;

    public OnItemButtonClickListener mOnItemButtonClickListener;

    public SCShopAdapter(Context context) {
        super(context);
    }

    @Override
    public void onBindHolder(BaseViewHolder<AdapterScShopBinding> holder, int pos) {
        holder.getBinding().setType(type);
        Glide.with(mContext).load(mList.get(pos).getImage()).into(holder.getBinding().imageShop);
        String Money = "";
        if (type == 1) {
            Money = "￥" + mList.get(pos).getGoods_price();
        }
        if (type == 2) {
            Money = mList.get(pos).getIntegral() + "积分 + ￥" + mList.get(pos).getGoods_price();
        }
        if (type == 3) {
            Money = mList.get(pos).getIntegral() + "易货积分";
        }
        holder.getBinding().tvMoney.setText(Money);
        if (mOnItemButtonClickListener != null)
            holder.getBinding().tvSee.setOnClickListener(v -> {
                mOnItemButtonClickListener.OnItemButtonClick(pos);
            });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.adapter_sc_shop;
    }

    public void setType(int type) {
        this.type = type;
    }

    public void setOnItemButtonClickListener(OnItemButtonClickListener mOnItemButtonClickListener) {
        this.mOnItemButtonClickListener = mOnItemButtonClickListener;
    }

    public interface OnItemButtonClickListener {
        void OnItemButtonClick(int type);
    }

}
